import BriefCard from '@/components/brief-card';
import { getBriefs } from '@/server/controllers/briefController';

const BriefPage = async ({ params }) => {
    const { secuCode } = await params;
    const briefs = await getBriefs(secuCode);

    if (Array.isArray(briefs) && briefs.length === 0) return <div>None</div>;

    const jyBrief = briefs.find((brief) => brief.brief_source === 'jy');
    const kplBrief = briefs.find((brief) => brief.brief_source === 'kpl');
    const thsBrief = briefs.find((brief) => brief.brief_source === 'ths');

    return (
        <div className="flex flex-col text-xs">
            {jyBrief && <BriefCard brief={jyBrief} />}
            {kplBrief && <BriefCard brief={kplBrief} />}
            {thsBrief && <BriefCard brief={thsBrief} />}
        </div>
    );
};

export default BriefPage;
